package com.site.web;

import com.night.common.entity.ResultVo;
import com.night.common.entity.logistical.Appointment;
import com.night.common.entity.logistical.Area;
import com.night.common.entity.logistical.vo.AppointmentVO;
import com.site.service.AppointmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.ParseException;
import java.util.Date;
import java.util.List;

/**
 * @ClassName: AppointmentController
 * @author: LJC
 * @date: 2022/10/23-10:36
 * 地预预约
 */
@RestController
@RequestMapping("/api/lot/apt")
public class AppointmentController {
    @Autowired
    private AppointmentService appointmentService;

    //添加预约接口
    @RequestMapping("/add")
    public ResultVo<?> add(@RequestBody AppointmentVO appointmentVO) throws ParseException {
        //
        System.out.println(appointmentVO);
        appointmentService.addAppointment(appointmentVO);
        return ResultVo.SUCCESS;
    }

    //查询所有预约
    @RequestMapping("/getAll")
    public ResultVo<?> getAll(){
        List<Appointment> list = appointmentService.getAllAppointment();
        return new ResultVo(200,"OK",list);
    }

    //根据id查询预约信息
    @RequestMapping("/getaptByid")
    public ResultVo<?> getaptByid(Appointment appointment){
        Appointment list = appointmentService.getAppointmentById(appointment);
        return new ResultVo(200,"OK",list);
    }

    //根据用户id查询预约信息
    @RequestMapping("/getaptByuserId")
    public ResultVo<?> getaptByuserId(Appointment appointment){
        List<Appointment> list = appointmentService.getAppointmentByUserId(appointment);
        return new ResultVo(200,"OK",list);
    }

    //获取开始时间和结束时间
    @RequestMapping("/getSTandET")
    public ResultVo<?> getSTandET(Appointment appointment){
        //

        return new ResultVo(200,"OK");
    }
}
